package com.cheetah.start.system.view.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.cheetah.start.common.annotation.NeedLogin;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * 奇怪加了前缀，静态资源访问不到 页面控制器
 *
 * @author xjhmwj
 * @date 2021/7/15 16:29
 */
@Api(tags = "页面跳转")
@Slf4j
@Controller
@RequestMapping()
public class ViewController {

    @GetMapping("/")
    public String blank() {
        return "/login";
    }

    /**
     * 登录
     *
     * @return {@link String}
     */
    @GetMapping("/login")
    public String login() {
        return "/login";
    }


    /**
     * 首页
     *
     * @return {@link String}
     */
    @NeedLogin
    @GetMapping("/index")
    public String index() {
        return "/index";
    }

    /**
     * 日志
     *
     * @return {@link String}
     */
    @SaCheckPermission(value = "sys:log:main", orRole = "admin")
    @GetMapping("/log")
    public String log() {
        return "/log/list";
    }


    /**
     * 字典
     *
     * @return {@link String}
     */
    @SaCheckPermission(value = "sys:dict:main", orRole = "admin")
    @GetMapping("/dict")
    public String dict() {
        return "/dict/list";
    }

    /**
     * 字典类型
     */
    @GetMapping("/dictType/add")
    public String dictTypeAdd() {
        return "/dict/add";
    }

    /**
     * dict数据添加
     *
     * @return {@link String}
     */
    @GetMapping("/dictData/add")
    public ModelAndView dictDataAdd(String typeCode) {
        ModelAndView model = new ModelAndView();
        model.addObject("typeCode", typeCode);
        model.setViewName("/dict/data/add");
        return model;
    }


    /**
     * 文件管理
     *
     * @return {@link String}
     */
    @SaCheckPermission(value = "sys:file:main", orRole = "admin")
    @GetMapping("/file")
    public String file() {
        return "/file/list";
    }

    /**
     * 其他管理
     *
     * @return {@link String}
     */
    @SaCheckPermission(value = "sys:other:main", orRole = "admin")
    @GetMapping("/other")
    public String other() {
        return "/other/list";
    }


    /**
     * 日志文件
     *
     * @return {@link String}
     */
    @SaCheckPermission(value = "sys:logfile:main", orRole = "admin")
    @GetMapping("/logfile")
    public String logFile() {
        return "/logfile/list";
    }

    /**
     * 菜单
     *
     * @return {@link String}
     */
    @SaCheckPermission(value = "sys:menu:main", orRole = "admin")
    @GetMapping("/menu")
    public String menu() {
        return "/menu/list";
    }

    /**
     * 菜单添加
     *
     * @return {@link String}
     */
    @GetMapping("/menu/add")
    public String menuAdd() {
        return "/menu/add";
    }
}
